#pragma once

namespace HTTP {

class Connection
{
public:
	Connection();

	bool Open(const CString &strUrl);
	bool Open(const CString &strUrl, const CString &headers);
	bool Send(const CString &strUrl, const CString &headers, const CStringA &body);
    DWORD GetStatusCode();
    CString GetLastModifiedHeader();
	bool GetResponse(CStringA& response);

	void Close();

	BOOL operator ! () const;

	~Connection();

protected:
	bool Connect(const CString &url, LPCTSTR pszMethod);

private:
	DWORD				m_context; 

	Internet			m_internet;
	InternetConnection	m_connection;
	InternetHttpRequest m_request;

private:
#ifdef _USE_LOGGING
	static CLogger logger;
#endif
};

} // namespace HTTP
